package cn.acmenms.po.serializ;


import cn.acmenms.utils.LocalDateTimeUtils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.time.LocalDateTime;

/**
 * @ClassName: CustomDateSerializer
 * @Description: 自定义友好日期格式序列化
 * @author: 神奇的鸭鸭
 * @Date: 2018/2/9 21:30
 */
public class FriendlyDateSerializer extends JsonSerializer<LocalDateTime> {

    @Override
    public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(LocalDateTimeUtils.friendlyTime(value));
    }
}